﻿//Write a program that reads two arrays from the console and compares them element by element.


namespace ComparesElements
{
    using System;

    public class ComparesElements
    {
        static Random randomGenerator = new Random();
        public static void Main(string[] args)
        {
            Random randomGenerator = new Random();
            Console.Write("Enter first array lenght: n = ");
            int firstArrayLenght = int.Parse(Console.ReadLine());
            int[] firstArray = new int[firstArrayLenght];
            Console.Write("Enter second array lenght: m = ");
            int secondArrayLenght = int.Parse(Console.ReadLine());
            int[] secondArray = new int[secondArrayLenght];
            Console.WriteLine();

            GenerateElements(firstArrayLenght, firstArray);
            GenerateElements(secondArrayLenght, secondArray);
            ShowArrayElements(firstArray, "first ");
            ShowArrayElements(secondArray, "second");
            Console.WriteLine();
            int lenght = Math.Min(firstArrayLenght, secondArrayLenght);
            for (int i = 0; i < lenght; i++)
            {
                if (firstArray[i] < secondArray[i])
                {
                    Console.WriteLine("{0} < {1}", firstArray[i], secondArray[i]);
                }
                else if (firstArray[i] > secondArray[i])
                {
                    Console.WriteLine("{0} > {1}", firstArray[i], secondArray[i]);
                }
                else
                {
                    Console.WriteLine("{0} = {1}", firstArray[i], secondArray[i]);
                }
            }
        }

        private static void GenerateElements(int arraysElementsCount, int[] arrays)
        {
            for (int i = 0; i < arraysElementsCount; i++)
            {
                arrays[i] = randomGenerator.Next(0, 101);
            }
        }

        private static void ShowArrayElements(int[] arrays, string arrayName)
        {
            Console.Write("Elements of {0} array are: ", arrayName);
            foreach (int element in arrays)
            {
                Console.Write(" " + element);
            }

            Console.WriteLine();
        }
    }
}
